* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: #f5f7fa;
            overflow: hidden;
        }

        .designer-container {
            display: flex;
            height: 100vh;
        }

        /* 左侧节点面板 */
        .node-panel {
            width: 280px;
            background: white;
            border-right: 1px solid #e8e8e8;
            display: flex;
            flex-direction: column;
        }

        .panel-header {
            padding: 10px 12px;
            border-bottom: 1px solid #e8e8e8;
            background: #fafbfc;
        }

        .panel-title {
            font-size: 14px;
            font-weight: 600;
            color: #333;
            margin-bottom: 4px;
        }

        .panel-subtitle {
            font-size: 11px;
            color: #666;
        }

        /* 参数定义区域 - 各占一半空间 */
        .node-panel > div:nth-child(2) {
            flex: 1;
            overflow-y: auto;
            min-height: 0;
        }

        .node-categories {
            flex: 1;
            padding: 8px 12px;
            overflow-y: auto;
            min-height: 0;
        }

        .node-category {
            margin-bottom: 12px;
        }

        .category-title {
            font-size: 12px;
            font-weight: 600;
            color: #333;
            margin-bottom: 6px;
            padding-left: 6px;
            border-left: 2px solid #4facfe;
        }

        /* 节点项容器 - 使用grid布局实现两列 */
        .node-category {
            display: grid;
            grid-template-columns: 1fr;
            gap: 4px;
        }

        .node-category .category-title {
            grid-column: 1 / -1;
        }

        /* 对于有多个节点的分类，使用两列布局 */
        .node-category:has(.node-item:nth-child(3)) {
            grid-template-columns: 1fr 1fr;
        }

        .node-item {
            display: flex;
            align-items: center;
            padding: 6px 6px;
            background: #f8f9ff;
            border: 1px solid #e1e5f2;
            border-radius: 4px;
            cursor: grab;
            transition: all 0.2s ease;
            user-select: none;
        }

        .node-item:hover {
            background: #e8f0fe;
            border-color: #4facfe;
            transform: scale(1.02);
        }

        .node-item:active {
            cursor: grabbing;
        }

        .node-icon {
            width: 16px;
            height: 16px;
            margin-right: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            flex-shrink: 0;
        }

        .node-info {
            flex: 1;
            min-width: 0;
            overflow: hidden;
        }

        .node-name {
            font-size: 10px;
            font-weight: 500;
            color: #333;
            margin-bottom: 1px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .node-desc {
            font-size: 8px;
            color: #666;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* 中间画布区域 */
        .canvas-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .canvas-toolbar {
            height: 50px;
            background: white;
            border-bottom: 1px solid #e8e8e8;
            display: flex;
            align-items: center;
            padding: 0 16px;
            gap: 12px;
        }

        .toolbar-btn {
            padding: 6px 12px;
            border: 1px solid #d0d7de;
            border-radius: 4px;
            background: white;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s;
        }

        .toolbar-btn:hover {
            background: #f3f4f6;
            border-color: #4facfe;
        }

        .toolbar-btn.primary {
            background: #4facfe;
            color: white;
            border-color: #4facfe;
        }

        .toolbar-btn.primary:hover {
            background: #2196f3;
        }

        .toolbar-btn[title] {
            position: relative;
        }

        #zoomLevel {
            font-weight: 600;
            color: #4facfe;
        }

        .canvas-container {
            flex: 1;
            position: relative;
            overflow: auto;
            background: 
                radial-gradient(circle at 50% 50%, #e3f2fd 1px, transparent 1px);
            background-size: 20px 20px;
        }

        .canvas {
            width: 100%;
            height: 100%;
            position: relative;
            transform-origin: 0 0;
            /* 移除transition，避免影响getBoundingClientRect的计算 */
        }

        /* 右侧属性面板 */
        .property-panel {
            width: 320px;
            background: white;
            border-left: 1px solid #e8e8e8;
            display: flex;
            flex-direction: column;
        }

        .property-content {
            flex: 1;
            padding: 16px;
            overflow-y: auto;
        }

        .property-section {
            margin-bottom: 24px;
        }

        .section-title {
            font-size: 14px;
            font-weight: 600;
            color: #333;
            margin-bottom: 12px;
            padding-bottom: 6px;
            border-bottom: 1px solid #eee;
        }

        .form-group {
            margin-bottom: 16px;
        }

        .form-label {
            display: block;
            font-size: 13px;
            font-weight: 500;
            color: #555;
            margin-bottom: 6px;
        }

        .form-input, .form-select, .form-textarea {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #d0d7de;
            border-radius: 4px;
            font-size: 13px;
            transition: border-color 0.2s;
        }

        .form-input:focus, .form-select:focus, .form-textarea:focus {
            outline: none;
            border-color: #4facfe;
            box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.1);
        }

        .form-textarea {
            resize: vertical;
            height: 80px;
            font-family: 'Courier New', monospace;
        }

        /* 画布节点样式 */
        .canvas-node {
            position: absolute;
            background: white;
            border: 2px solid #d0d7de;
            border-radius: 8px;
            padding: 12px;
            min-width: 120px;
            width: 120px; /* 固定宽度确保一致性 */
            height: 80px; /* 固定高度确保一致性 */
            min-height: 80px;
            cursor: move;
            user-select: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transition: all 0.2s ease;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .canvas-node:hover {
            border-color: #4facfe;
            box-shadow: 0 4px 12px rgba(79, 172, 254, 0.2);
        }

        .canvas-node.selected {
            border-color: #4facfe;
            box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.3);
        }

        .canvas-node.input {
            border-color: #28a745;
            background: linear-gradient(135deg, #d4edda, #f8f9fa);
        }

        .canvas-node.math {
            border-color: #ffc107;
            background: linear-gradient(135deg, #fff3cd, #f8f9fa);
        }

        .canvas-node.function {
            border-color: #17a2b8;
            background: linear-gradient(135deg, #d1ecf1, #f8f9fa);
        }

        .canvas-node.condition {
            border-color: #fd7e14;
            background: linear-gradient(135deg, #ffeaa7, #f8f9fa);
        }

        .canvas-node.output {
            border-color: #6f42c1;
            background: linear-gradient(135deg, #e2d9f3, #f8f9fa);
        }

        .canvas-node.constant {
            border-color: #e83e8c;
            background: linear-gradient(135deg, #fde2e7, #f8f9fa) !important;
            width: 120px !important; /* 强制设置宽度 */
            min-width: 120px !important;
            max-width: 120px !important;
            height: 80px !important; /* 强制设置高度 */
            min-height: 80px !important;
            max-height: 80px !important;
        }

        /* 确保常量节点内的输入框样式一致 */
        .canvas-node.constant input,
        .canvas-node.constant select {
            width: calc(100% - 16px) !important;
            min-width: 88px !important;
            max-width: 88px !important;
            box-sizing: border-box;
            font-size: 14px !important;
            font-weight: 600 !important;
            text-align: center !important;
            border: 1px solid #d0d7de;
            border-radius: 4px;
            padding: 4px 8px;
            margin: 0 !important;
            height: 28px;
            line-height: 20px;
        }

        .canvas-node.constant input:focus,
        .canvas-node.constant select:focus {
            outline: none;
            border-color: #e83e8c;
            box-shadow: 0 0 0 2px rgba(232, 62, 140, 0.1);
        }

        .canvas-node.branch {
            border: 2px solid;
            border-radius: 10px;
        }

        .canvas-node.branch.if {
            border-color: #007bff;
            background: linear-gradient(135deg, #cce5ff, #f8f9fa);
        }

        .canvas-node.branch.elsif {
            border-color: #ffc107;
            background: linear-gradient(135deg, #fff3cd, #f8f9fa);
        }

        .canvas-node.branch.else {
            border-color: #dc3545;
            background: linear-gradient(135deg, #f8d7da, #f8f9fa);
        }

        .node-header {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
            flex-shrink: 0;
        }

        .node-title {
            font-size: 14px;
            font-weight: 600;
            color: #333;
            flex: 1;
        }

        .node-close {
            width: 16px;
            height: 16px;
            border: none;
            background: #dc3545;
            color: white;
            border-radius: 50%;
            cursor: pointer;
            font-size: 10px;
            line-height: 1;
        }

        .node-content {
            font-size: 11px;
            color: #666;
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            overflow: hidden;
        }

        /* 参数节点内容文本省略 */
        .canvas-node.input .node-content > div {
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            box-sizing: border-box;
        }

        /* 参数值显示区域特殊处理 */
        .canvas-node.input .node-content div[style*="background: white"] {
            max-width: calc(100% - 8px);
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* 通用节点内容文本省略 */
        .canvas-node .node-content div {
            max-width: 96px; /* 节点宽度120px - 左右padding 24px */
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            box-sizing: border-box;
        }

        .node-ports {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none; /* 让点击事件穿透到下层元素 */
        }

        .node-port {
            width: 12px;
            height: 12px;
            background: #4facfe;
            border-radius: 50%;
            position: absolute;
            cursor: crosshair;
            border: 2px solid white;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
            transition: all 0.2s ease;
            pointer-events: all; /* 端口本身可以响应点击 */
        }

        .node-port:hover {
            transform: scale(1.2);
            box-shadow: 0 4px 8px rgba(0,0,0,0.3);
        }

        .port-input {
            top: -6px;
            background: #28a745;
        }

        .port-output {
            bottom: -6px;
            background: #dc3545;
        }

        /* 不同类型端口的颜色 */
        .port-type-number {
            background: #007bff !important; /* 蓝色代表数字 */
        }

        .port-type-boolean {
            background: #28a745 !important; /* 绿色代表布尔 */
        }

        .port-type-string {
            background: #ffc107 !important; /* 黄色代表字符串 */
        }

        .port-type-any {
            background: #6c757d !important; /* 灰色代表任意类型 */
        }


        /* 连接线样式 */
        .connection-line {
            position: absolute;
            pointer-events: none;
            z-index: 1;
        }

        .connection-path {
            stroke: #4facfe;
            stroke-width: 2;
            fill: none;
            cursor: pointer;
            pointer-events: stroke;
            transition: all 0.2s ease;
        }

        .connection-path:hover {
            stroke: #ff4757;
            stroke-width: 3;
            filter: drop-shadow(0 0 4px rgba(255, 71, 87, 0.5));
        }

        /* 连接线的删除按钮 */
        .connection-delete-btn {
            cursor: pointer;
            pointer-events: all;
            opacity: 0.7;
            transition: opacity 0.2s ease;
        }

        .connection-delete-btn:hover {
            opacity: 1;
        }

        .connection-delete-btn circle {
            fill: #ff4757;
            transition: all 0.2s ease;
        }

        .connection-delete-btn text {
            fill: white;
            font-size: 12px;
            font-weight: bold;
            pointer-events: none;
            user-select: none;
        }

        .connection-delete-btn:hover circle {
            fill: #dc3545;
        }

        /* 预览面板 */
        .preview-panel {
            background: #f8f9fa;
            border-top: 1px solid #e8e8e8;
            padding: 12px 16px;
            max-height: 200px;
            overflow-y: auto;
        }

        .preview-title {
            font-size: 12px;
            font-weight: 600;
            color: #333;
            margin-bottom: 8px;
        }

        .preview-content {
            padding: 16px;
            line-height: 1.6;
        }
        
        .formula-display {
            font-size: 16px;
            font-weight: 600;
            color: #4facfe;
            font-family: 'Courier New', monospace;
            margin: 0 0 12px 0;
            word-wrap: break-word;
        }
        
        .result-display {
            font-size: 18px;
            font-weight: 700;
            color: #28a745;
            margin: 0 0 8px 0;
        }
        
        .formula-label {
            font-size: 14px;
            font-weight: 600;
            color: #333;
            margin-right: 8px;
        }
        
        .result-label {
            font-size: 14px;
            font-weight: 600;
            color: #333;
            margin-right: 8px;
        }

        /* 拖拽提示 */
        .drop-hint {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: #999;
            font-size: 14px;
            user-select: none;
        }

        .drop-hint-icon {
            font-size: 48px;
            margin-bottom: 12px;
            opacity: 0.3;
        }

        /* 响应式 */
        @media (max-width: 1024px) {
            .node-panel, .property-panel {
                width: 250px;
            }
        }


        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }

        ::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 3px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #a8a8a8;
        }

        /* Tooltip样式 */
        .port-tooltip {
            position: absolute;
            background: rgba(0, 0, 0, 0.9);
            color: white;
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 11px;
            white-space: nowrap;
            z-index: 9999;
            pointer-events: none;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.2s ease;
            max-width: 300px;
            line-height: 1.4;
        }

        .port-tooltip.show {
            opacity: 1;
        }

        .port-tooltip::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border: 5px solid transparent;
            border-top-color: rgba(0, 0, 0, 0.9);
        }

        /* 参数抽屉样式 */
        .param-drawer {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 10000;
            display: none;
        }

        .param-drawer.show {
            display: block;
        }

        .param-drawer-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            animation: fadeIn 0.3s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        .param-drawer-content {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            width: 400px;
            background: white;
            box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
            display: flex;
            flex-direction: column;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from { transform: translateX(100%); }
            to { transform: translateX(0); }
        }

        .param-drawer-header {
            padding: 20px 24px;
            border-bottom: 1px solid #e8e8e8;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #fafbfc;
        }

        .param-drawer-title {
            display: flex;
            align-items: center;
            gap: 12px;
            font-size: 18px;
            font-weight: 600;
            color: #333;
        }

        .param-drawer-title span:first-child {
            font-size: 24px;
        }

        .param-drawer-close {
            width: 32px;
            height: 32px;
            border: none;
            background: transparent;
            color: #666;
            font-size: 24px;
            cursor: pointer;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .param-drawer-close:hover {
            background: #f0f0f0;
            color: #333;
        }

        .param-drawer-body {
            flex: 1;
            padding: 24px;
            overflow-y: auto;
        }

        .param-drawer-field {
            margin-bottom: 20px;
        }

        .param-drawer-label {
            display: block;
            font-size: 14px;
            font-weight: 500;
            color: #333;
            margin-bottom: 8px;
        }

        .param-drawer-label .required {
            color: #dc3545;
            margin-left: 2px;
        }

        .param-drawer-input,
        .param-drawer-select,
        .param-drawer-textarea {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #d0d7de;
            border-radius: 6px;
            font-size: 14px;
            transition: all 0.2s;
            font-family: inherit;
        }

        .param-drawer-input:focus,
        .param-drawer-select:focus,
        .param-drawer-textarea:focus {
            outline: none;
            border-color: #4facfe;
            box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
        }

        .param-drawer-textarea {
            resize: vertical;
            min-height: 80px;
            font-family: 'Courier New', monospace;
        }

        .param-drawer-hint {
            font-size: 12px;
            color: #666;
            margin-top: 6px;
            line-height: 1.5;
        }

        .param-drawer-footer {
            padding: 16px 24px;
            border-top: 1px solid #e8e8e8;
            display: flex;
            gap: 12px;
            justify-content: flex-end;
            background: #fafbfc;
        }

        .param-drawer-btn {
            padding: 10px 20px;
            border: 1px solid #d0d7de;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
        }

        .param-drawer-btn-cancel {
            background: white;
            color: #333;
        }

        .param-drawer-btn-cancel:hover {
            background: #f6f8fa;
            border-color: #4facfe;
        }

        .param-drawer-btn-save {
            background: #4facfe;
            color: white;
            border-color: #4facfe;
        }

        .param-drawer-btn-save:hover {
            background: #2196f3;
            border-color: #2196f3;
        }

        .param-drawer-btn-delete {
            background: white;
            color: #dc3545;
            border-color: #dc3545;
            margin-right: auto;
        }

        .param-drawer-btn-delete:hover {
            background: #dc3545;
            color: white;
        }

        /* 简洁的参数列表项 */
        .param-list-item {
            display: flex;
            align-items: center;
            padding: 8px 10px;
            margin-bottom: 4px;
            background: white;
            border: 1px solid #e1e5e9;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
            user-select: none;
        }

        .param-list-item:hover {
            background: #f8f9fa;
            border-color: #4facfe;
            box-shadow: 0 2px 4px rgba(79, 172, 254, 0.1);
        }

        .param-list-item.dragging {
            opacity: 0.5;
        }

        .param-list-icon {
            width: 24px;
            height: 24px;
            margin-right: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            flex-shrink: 0;
        }

        .param-list-info {
            flex: 1;
            min-width: 0;
        }

        .param-list-name {
            font-size: 13px;
            font-weight: 500;
            color: #333;
            margin-bottom: 2px;
        }

        .param-list-meta {
            font-size: 10px;
            color: #666;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .param-list-type {
            padding: 1px 6px;
            background: #e8f0fe;
            color: #4facfe;
            border-radius: 3px;
            font-weight: 500;
        }

        .param-list-value {
            color: #666;
            font-family: 'Courier New', monospace;
        }

        .param-list-drag-icon {
            color: #ccc;
            font-size: 16px;
            margin-left: 8px;
        }

        .param-list-item:hover .param-list-drag-icon {
            color: #4facfe;
        }